home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Mops 2.5 / Quick Edit ƒ / Subject Glossary / Compiler < prev    next >
Encoding:
Text File  |  1993-02-27  |  11.1 KB  |  272 lines  |  [TEXT/MSET]

  1.  
  2. (    --
  3.     Left paren.  Denotes the beginning of a comment.  At least one 
  4.     space must follow.  End comment with a right paren ).  
  5. )    --
  6.     Right paren.  Denotes the end of a comment that was begun by ( .
  7.  
  8. \    --    Backslash.  Will cause compiler to ignore the rest of that line.
  9.  
  10. ENDLOAD      Will cause compiler to ignore the rest of the file being loaded.
  11.  
  12. VECT    cfa --  :  name
  13.     Defines an execution variable that can hold and execute the cfa 
  14.     of a Mops word.  Executing the vect name will execute the cfa.
  15.     Can use -> at runtime to change.  
  16.  
  17.  
  18. STATE    --  compile-state
  19.     This value is the compilation state of the Mops interpreter.  A non-zero 
  20.     value means that the definition of a word, method, or class is being compiled.  
  21.  
  22. CSTATE    -- b
  23.     This value is a boolean which is true while a class is being compiled.  It is 
  24.     analogous to state which is true while a colon word is being compiled.  
  25.  
  26. ?COMP    --
  27.     Prints message: "compilation only" if not compiling, that is, if state is not 
  28.     zero 
  29.     
  30. [    --
  31.     So now [ and ] do double duty.  If they follow a method selector, they cause a 
  32.     late bind as in Neon.  In any other context they turn compilation on and off.  
  33.  
  34. $    -- n
  35.     Will compile the ensuing characters in the input stream as a hex 
  36.     number.  
  37. LIT    n --
  38.     A state-smart version of LITERAL.  Corresponds to LITERAL in Fig-Forth or 
  39.     original Neon, whereas our present LITERAL is Forth-83.  
  40. LITW    n --    
  41.  
  42.  
  43.  
  44. In Neon, ' (tick) was state-smart, following Fig-Forth.  We have 
  45. now followed the Forth-83 and ANSI standards in replacing the 
  46. state-smart tick with the two state-dumb forms ' (which ticks the 
  47. next word in the input stream at run time, no matter what) and 
  48. ['] which is immediate, must be used in a definition, and 
  49. compiles a literal fetch of the cfa of the following word.  
  50.  
  51. '    -- cfa  : word        compilation only
  52. [']    -- cfa  : word        runtime only
  53.  
  54.  
  55.  
  56. .ID    ?cfa --
  57.     If addr looks like a cfa with a name, prints the name.  If it 
  58.     looks like a cfa without a name, prints "(no name)".  Otherwise 
  59.     doesn't print anything.  
  60.  
  61. XTS{    --  :  name1 name2 etc.
  62.     State-smart word to compile or stack a list of xts.  Pulls words from stream, 
  63.     until "}". 
  64.     
  65. ?#XTS    n1 n2 --
  66.     Used to check that the right number of stacked cfas is being passed in.
  67.  
  68. :    --  :  name
  69.     Creates a dictionary entry for the next word in the input stream.  
  70.     standard 
  71. ;    --    standard
  72.  
  73. For defining action handlers that cross module bounds.  If a class is defined 
  74. in module1, but instantiated in module2 with action handlers in module2, define 
  75. handlers with :a ...  ;a.  
  76. :A    --
  77. ;A    --
  78.  
  79. ,EXEC    cfa n --
  80.     State-smart execute.  If used within a program definition, compiles the cfa as 
  81.     a literal to be executed at runtime; otherwise executes it immediately.  This 
  82.     is not an immediate word.  It is useful in building compiler words which 
  83.     conditionally compile other words. 
  84.     
  85. 0,    --    Compiles an empty cell.
  86. ,    n --    Compiles 4-byte n into the next available dictionary address.
  87. C,    w --    Compiles 1-byte c into the next available dictionary address.
  88. W,    w --    Compiles 2-byte w into the next available dictionary address.
  89.  
  90. Forward    --  : name
  91.     Creates a word which is to be defined later with :f, the special colon compiler 
  92.     for forward-referenced Yerk words, because :f makes the word behave like a 
  93.     colon definition.  If you forget to define a forward-referenced word, the word 
  94.     issues the message: "Unresolved forward reference to: AWORD at address: XXXX" 
  95.     and aborts.  To forward reference an object, define a value having the same 
  96.     name as the object-to-be.  Later create the object as you would normally.  
  97.  
  98. :F    --  : name
  99.     Begins compilation of a word which was previously 
  100.     forward-referenced.  :f creates a headerless entry for the word 
  101.     and then patches the previous entry to point to the newly 
  102.     compiled definition.  Forward-referencing is useful when a word 
  103.     is to be used before it can be defined.  You end the compilation 
  104.     with ;f.
  105.     
  106. ;F    --
  107.     Ends compilation of a word which was defined with :f.  See forward.
  108.  
  109. IMMEDIATE    --    standard
  110.  
  111. INLINE{    --  : word ... }
  112.     Commences a piece of inline code.  Allows faster execution.  We assume that 
  113.     inline code chunks will be fairly short, and are to be optimized for speed.  
  114.  
  115.  
  116. EVALUATE    addr len --
  117.     ANSI standard.  Makes the passed-in string the input stream for 
  118.     interpretation or compilation, until it is exhausted. 
  119.     
  120. EX-GEN    cfa --
  121.     "Execute general".  Executes the word with the given cfa.  The word may be 
  122.     anything.  It is executed by compiling it into a temporary buffer, then 
  123.     branching there.  Slower than Execute, but unlike Execute, will really execute 
  124.     anything.  
  125.  
  126. EX-METHOD    obj cfa --
  127.     Executes the method with the given cfa, using the given object.
  128.  
  129. EXECUTE    cfa --    standard
  130.  
  131. EXN    cfa n --
  132.     is to EX-GEN what (COMPN) is to (COMP).  It has the additional parameter n 
  133.     which is action code for -> ++> etc.  Because this can be called from EX-GEN 
  134.     (which may be executing a prefix op), we use the alternate execution buffer 
  135.     ExBuf1.  
  136.  
  137. INTERPRET
  138.     is the interpretation loop.  Words from the input stream are interpreted 
  139.     until the input is exhausted.  
  140.  
  141. INTRP1    --  : word    Interprets one word/number from the input stream.
  142.  
  143. PATCHES_DONE    --
  144.     If you ever need to patch instructions, call this when you're finished.  It 
  145.     flushes the instruction cache if necessary to make sure that the new 
  146.     instructions will really be executed.  PATCH and (PATCH) call it already, so if 
  147.     you are using these, you don't need to call Patches_done.  
  148.  
  149. POSTPONE    --
  150.     In this system, compilation is done by executing the compilation handler for 
  151.     the word in question.  POSTPONE must therefore be immediate, and compile the 
  152.     right code into the client definition.  This code consists of a literal push of 
  153.     the POSTPONEd word's cfa, then a call to (COMP).  
  154.  
  155. QUIT    --    standard
  156.  
  157. TYPE{    --  :  name1 name2 etc.
  158.     TYPE{ defines a Pascal-like enumerated type.  At this stage we don't give a 
  159.     name to the "type" as such, as we can't do anything really sensible with it.  
  160.     However later we can optionally load the ENUM-TYPE class which is rather more 
  161.     Pascal-like.  But even without that, the enumeration is useful by itself.  
  162.  
  163. {    --
  164.     Used to begin list of local variables and named input parameters.  Note 
  165.     that the compiler willfirst search this list, so these names take 
  166.     precedence over other names in the dictionary.  
  167.  
  168. TRAV    cfa parm --
  169.     Traverses the dictionary, passing each cfa and the parm to the passed-in 
  170.     proc.  
  171.  
  172. TRAV-FROM    cfa parm addr --
  173.     As for TRAV, but starts from the first word whose lfa is below or at the 
  174.     given address.  
  175.  
  176. TRAVERSE    ?    
  177.  
  178. RESERVE    n --    Allots the next n bytes in the dictionary and erases them.
  179.  
  180. REVEAL    --    Makes the current name visible again. See hide.
  181.  
  182. NAME?    addr -- addr b
  183.     Returns True if the passed-in addr appears to be a cfa with a corresponding 
  184.     valid name field.  
  185. OBJ?    obj? -- obj? class  |  -- ^obj? 0
  186.     General test for an object.  Not completely rigorous, so we shouldn't use 
  187.     it in a TRAV, but pretty good nevertheless.  If it is an object, the class 
  188.     is left in theClass.  We do assume the passed-in value may not be a legal 
  189.     address at all.  
  190. OBJCFA?    cfa -- cfa b
  191.     Returns true if the cfa refers to a dictionary object.  Note: this won't 
  192.     work for a heap object, since we rely on the unique handler code for 
  193.     objects being there, and it won't be for heap objects.  But this is the 
  194.     only way to get a really rigorous check, which we need for TRAV.  We assume 
  195.     cfa is really a cfa.  
  196. HERE    -- addr    Returns the next available dictionary location.
  197. HIDE    --
  198.     Replace Smudge in Neon.  HIDE hides the last dictionary header so that FIND 
  199.     won't find it.  REVEAL brings it back again.  Use this if you want the 
  200.     previous use of the name, i.e.  if you DON'T want recursion.  
  201. L>NAME    ?    
  202. latest    -- nfa-1    A value. Leaves the nfa-1 of the last defined word.
  203. LINK>    ?    
  204. N>COUNT    nfa  -- addr len
  205.     Leaves the address and length of a name field, suitable for use by "type".
  206. N>LINK    ?    
  207. >BODY    ?    
  208. >CLASS    obj -- class | -- 0
  209.     Converts an object address to its class address.  Returns zero if the 
  210.     passed-in address isn't an object address.  Needs to work for heap as well 
  211.     as dictionary objects.  The test is very unlikely (maybe 1/2**24) to 
  212.     indicate a non-object as being an object.  Without tagged storage we can't 
  213.     be absolutely sure.  To save time we don't do a conservative check on ^obj 
  214.     actually being a legal address (unlike CFA?), apart from checking that it 
  215.     is even, which is a very quick check.  This means we may crash if an even 
  216.     but illegal address is passed in.  The presumption is that it really is an 
  217.     object address, and that anything else is an (unlikely) error.  
  218. >ClassCfa    obj -- class | -- 0
  219.     As for >CLASS, but if the class is exported from a module and you are 
  220.     executing in the main dictionary, it gives the cfa of the imported word, 
  221.     without accessing the module.  This can be useful if you just want to 
  222.     identify a class without needing all the class info.  If you are executing 
  223.     in the module, however, you will get the cfa of the class in the module.  
  224.     The general rule is that the returned cfa will always be the same as if you 
  225.     had just ticked the classname, wherever you are executing.  
  226. >HDLR    ?    
  227. >LINK    ?    
  228. >NAME    cfa -- nfa    Returns the name field address (nfa) for the given cfa.
  229. NAME>    ?    
  230. ENDTRAV?    -- b
  231.     A value.  May be set from within a trav handler to terminate the trav.
  232. fence    -- addr
  233.     A value. Leaves the address below which forget will not operate.
  234. FIND    str-addr -- cfa flag  |  -- F
  235.     Forth-83/ANSI standard.  As in Neon, calls the vectored uFind first, then 
  236.     simply returns if uFind returns a non-zero n.  In all cases, if the search 
  237.     succeeds, addr' is the cfa of the found dictionary entry, and n is -1 for a 
  238.     non-immediate word and 1 for an immediate word.  If the search fails, n is 
  239.     zero and addr' is the same as str-addr.  
  240. FORGET    -- : word
  241.     Deletes the word from the dictionary and ALL entries above it (i.e., in 
  242.     higher memory).  Issues message "in protected dictionary" if the word is 
  243.     below fence, and aborts.  
  244. DEFINED?    -- addr n  : word
  245.     Defined as  MWORD FIND.  Does a FIND on the next word in the input stream.
  246. DOES>    --
  247.     Defines the runtime action of a word defined with <builds.
  248. <BUILDS    --  :  name
  249.     We retain <BUILDS to be used in conjunction with DOES> rather than 
  250.     following the standard and using CREATE.  This is because CREATEd words 
  251.     have the data right at the cfa, while DOES> words have to have a pointer to 
  252.     the DOES> code.  So rather than waste space in CREATEd words or do a 
  253.     complicated kludge during compilation, we use <BUILDS.  
  254. DP    -- addr
  255.     A value.  Leaves the address of the next memory location above the 
  256.     dictionary.  
  257. CONTEXT    -- addr    
  258. CREATE    --  : name
  259.     This is now Forth-83/ANSI.  Creates a dictionary header using the next word 
  260.     in the input stream.  If this new word is executed, it returns its pfa.  
  261.     What we actually do is to call HEADER, then add in the appropriate handler 
  262.     code.  
  263. ALIGN-DP    --    If the DP is odd, adds one to it.
  264. ALLOT    n --
  265.     Reserves n additional bytes for the code field of the last defined 
  266.     dictionary entry.  
  267. CELLS    #cells -- #bytes
  268.     Given the number of cells, returns the number of bytes required (#bytes = 4 
  269.     x #cells).  
  270. CFA?    cfa? -- cfa? b    Checks if cfa? could really be a CFA.
  271. CLASS?    cfa? -- cfa? b    Returns true if the cfa refers to a class.
  272.